﻿@{
    ViewBag.Title = "PaymentInfo";
}

@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <link href="~/Scripts/miniui/themes/default/medium-mode.css" rel="stylesheet" type="text/css" />       
}

<form id="form1" method="post">
            @Html.Partial("~/Views/Modular/Toolbars.cshtml")
        <div name="Base" title="收付款项目" style="height:100%;overflow:hidden;margin-top:15px;margin-left:20px">
            <table>
                <tr>
                    <td width="80px" height ="50px" align="right">
                        项目类型：</td>
                    <td width="250px" height ="50px">
                        <input name="FTypeID" id="FTypeID" class="mini-combobox" style="width:250px;" showNullItem="false" 
                                allowInput="false" align="left" value ="1" data ="comType" TabIndex="1"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="50px" align="right">
                        项目编码：</td>
                    <td width="250px" height ="50px">
                        <input name="FNumber" id="FNumber" class="mini-textbox" style="width:250px;" readonly="true" value="" TabIndex="2"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="50px" align="right">
                        项目名称：</td>
                    <td width="250px" height ="50px">
                        <input id="FName" name="FName" class="mini-textbox " style="width:250px;" TabIndex="3"/>
                    </td>
                </tr>
                <tr>
                    <td width="80px" height ="50px" align="right">
                        &nbsp;&nbsp;备&nbsp;&nbsp;注：</td>
                    <td width="250px" height ="50px">
                        <input id="FRemark" name="FRemark" class="mini-textbox " style="width:250px;"  TabIndex="4"/>
                    </td>
                </tr>
            </table>
            <br />
        </div>
    <input name="FItemID" class="mini-hidden" />
</form>

<script>
    var comType = [{ "id": "1", "text": "付款类型" },
                { "id": "2", "text": "收款类型" }]

    function FormShown() {
        mini.parse();
        LoadListData();
    }

    //加载资料
    function SetInfoData(data) {
        if (data.action == "new") {
            NewInfo();
        }
        else {
            $.post("GetItem", { mjson: "[{'FItemID':'" + data.FItemID + "','mSystemAppID':'" + parent.window.getSystemAppID() + "'}]" }, function (data) {
                var form = new mini.Form("form1");
                var mdata = mini.decode(data);
                form.setData(mdata.data[0]);
            });
        }
    }

    //新增资料
    function NewInfo() {
        mini.getbyName("FTypeID").setValue(1);
        mini.getbyName("FItemID").setValue("0");
        mini.getbyName("FNumber").setValue("");
        mini.getbyName("FName").setValue("");
        mini.getbyName("FRemark").setValue("");
        var jsonstr = '{"mSystemAppID":"' + parent.window.getSystemAppID() + '"}';
        $.post('NewInfo', { json: jsonstr }, function (data) {
            mini.getbyName("FNumber").setValue(data);
        });
    }

    function Validata() {
        if (mini.getbyName("FNumber").getValue() == '') {
            mini.alert("收付款项目编码不能为空");
            return false;
        }
        if (mini.getbyName("FName").getValue() == '') {
            mini.alert("名称不能为空");
            return false;
        }
        if (mini.getbyName("FNumber").getValue().length>50) {
            mini.alert("收付款项目编码不能超过50个字符");
            return false;
        }
        if (mini.getbyName("FName").getValue().length>50) {
            mini.alert("名称不能超过50个字符");
            return false;
        }
        if (mini.getbyName("FRemark").getValue().length > 100) {
            mini.alert("备注不能超过100个字符");
            return false;
        }
    }

    //保存资料
    function SaveInfo() {
        mini.getbyName("SaveInfo").setEnabled(false);
        if (Validata() == false) {
            mini.getbyName("SaveInfo").setEnabled(true);
            return;
        }
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            mini.getbyName("SaveInfo").setEnabled(true);
            return;
        }
        var data = form.getData(true, false);

        var json = mini.encode(data);
        $.post("SaveItem", { json: json, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                mini.alert(ret.msg, '提示', function () { CloseWindow(); });
                //mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                //NewInfo();
            }
            else {
                mini.alert("异常:" + ret.error);
            }
            mini.getbyName("SaveInfo").setEnabled(true);
        });
    }

</script>